package week9;

import java.util.Scanner;

public class PP1101 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String string = "";
        StringTooLongException exception = new StringTooLongException();
        while (!string.equals("DONE")){
            try {
                System.out.println("输入字符串: ");
                string = scan.next();
                if (string.length() > 20);
                throw exception;
            }catch (StringTooLongException e){
                System.out.println(e.toString());
                System.exit(0);
            }
        }System.out.println("结束.");
    }

    public static class StringTooLongException extends Exception{
        StringTooLongException(){
            super("字符串过长。");
        }
    }
}
